<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>支点信息</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/laypage.css">

    <script src="/js/vue/vue.min.js"></script>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
</head>
<body>
<section id="container">
<#include "sider.ftl">  <#--引入头部和导航栏-->
<#--本页为模板，请大家复制之后使用，不要直接在模板上加东西-->
<#--大家在测试自己的页面时，在controller中TestController     test3.do进行测试      在地址栏输入localhost:8080/test3.do-->
    <section id="main-content">
        <section class="wrapper">
            <div class="table-agile-info">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        分支信息审核管理
                    </div>


                    <div id="app" >
                        <form class="form-inline bg-info" role="form">
                            支点名称：
                            <div class="form-group">
                                <label class="sr-only" for="bname">支点名称:</label>
                                <input type="text" class="form-control" id="bname"  name="bname" placeholder="支点名称">
                            </div>
                            <button type="button" id="findBranch" class="btn btn-success">查询支点</button>
                        </form>

                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                <tr class="success">
                                    <th >编号</th>
                                    <th>名称</th>
                                    <th>电话</th>
                                    <th>城市</th>
                                    <th>详细地址</th>
                                    <th>负责人</th>
                                    <th>负责人电话</th>
                                    <th>经度</th>
                                    <th>维度</th>
                                    <th>创建日期</th>
                                    <th>备注</th>
                                    <th>审核状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr class="active" v-for="(item,index) in result">
                                    <td>{{index+1}}</td>
                                    <td>{{item.bname}}</td>
                                    <td>{{item.btelephone}}</td>
                                    <td>{{item.bcity}}</td>
                                    <td>{{item.blocation}}</td>
                                    <td>{{item.uname}}</td>
                                    <td>{{item.phone}}</td>
                                    <td>{{item.blongitude}}</td>
                                    <td>{{item.bdimension}}</td>
                                    <td>{{item.bstartdate}}</td>
                                    <td>{{item.bdesc}}</td>
                                    <td>
                                        <span v-if="item.bstate==0" style="color: orange">等待审核</span>
                                        <span v-if="item.bstate==1" style="color: limegreen">审核通过</span>
                                        <span v-if="item.bstate==2" style="color: red">审核不通过</span>
                                    </td>
                                    <td><a href="#" @click="checkEvent(item.buuid,item.bstate)" id="a">审核</a>
                                </tr>
                                </tbody>
                                <tr>
                                    <td colspan="3"><div id="pagenav"></div></td>
                                </tr>
                            </table>
                        </div>

                    </div>
                </div>
        </section>
    <#include "/foot.html"><#--引入底部-->
    </section>

</body>
</html>
<script type="text/javascript">
    var app=new Vue({
        el:"#app",
        data:{
            result:[]
        }
    });
    var getBranchList=function (curr) {
        $.ajax({
            type:"POST",
            url:"/branch/getBranchList.do",
            dataType:"json",
            data:{
                pageNo:curr||1,
                pageSize:5,
                keyword:$("#bname").val()
            },
            success:function (msg) {
                app.result=msg.page;
                laypage({
                    cont:"pagenav",
                    pages:msg.totalPage,
                    skin:"#CD00CD",
                    first:"第一页",
                    last:"最后一页",
                    curr:curr||1,
                    jump:function (obj,first) {
                        if(!first){
                            getBranchList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getBranchList();

    $("#findBranch").click(function () {
        getBranchList();
    });

    $("#bname").keyup(function () {
        getBranchList();
    })

    var checkEvent=function (buuid,bstate) {
        if(bstate==1||bstate==2){
            layer.msg("已经审核过了",{icon:2});
            return;
            /*alert(caseState)*/
        }
        layer.confirm('是否通过？',{
                    btn:['通过','不通过','取消']
                },function () {
                    $.ajax({
                        type:'POST',
                        url:'/check/changeBranchState.do',
                        data:{
                            buuid:buuid,
                            bstate:1
                        },
                        success:function (msg) {
                            if (msg=="true"){
                                layer.msg('审核通过',{icon:6});
                                getBranchList();
                            }else {
                                layer.msg('操作失败',{icon:2});
                                getBranchList();
                            }
                        }
                    });
                },function () {
                    $.ajax({
                        type:'POST',
                        url:'/check/changeBranchState.do',
                        data:{
                            buuid:buuid,
                            bstate:2
                        },
                        success:function (msg) {
                            if(msg=="true"){
                                layer.msg('审核不通过',{icon:5});
                                getBranchList();
                            }else{
                                layer.msg('操作失败',{icon:2});
                                getBranchList();
                            }
                        }
                    });
                },function () {

                }
        );
    }
</script>